FBDEditor.model.prototype.oberonCodeCreator = function ( moduleId, x ) {
/*
    oberonCodeCreator for FBDEditor 1.0
    Copyright (C) 2008-2009 Yuriy Butenko y.v.butenko@gmail.com

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/// x: { "v":[..], "f":[..], "i":[..], "o":[..], "txt":[..] };
	var res = 'MODULE ' + moduleId + ';\n\n';
	res += 'TYPE\ntype = RECORD\n';
	var regExpIdTp = /^\s*([^\s]+)\s*(\:\s*([^\s]*)\s*)?$/;
	res += '(* Inputs *)\n';
	for ( var i in x.i ) {
		var r = regExpIdTp.exec( x.i[i] );
		res += '\t' + r[1] + '*:' + ( r[3] || "LONGINT" ) + ';\n';
	};
	res += '(* Outputs *)\n';
	for ( var i in x.o ) {
		var r = regExpIdTp.exec( x.o[i] );
		res += '\t' + r[1] + '-:' + ( r[3] || "LONGINT" ) + ';\n';
	};
	res += '(* FB *)\n';
	for ( var i in x.f ) {
		var cls = x.f[i][1];
		var r = regExpIdTp.exec( x.f[i][0] );
		res += '\t' + r[1] + ':' + cls + ';\n';
	};
	for ( var i in x.v ) {
		var r = regExpIdTp.exec( x.v[i] );
		res += '\t' + r[1] + ':' + ( r[3] || "LONGINT" ) + ';\n';
	};
	res += 'END;\n\n';
	res += 'PROCEDURE (VAR this:type) init;\nBEGIN\n';
	for ( var i in x.f ) {
		var r = regExpIdTp.exec( x.f[i][0] );
		res += '\tthis.' + r[1] + '.init();\n';
	};
	res += 'END init;\n\n';
	res += 'PROCEDURE (VAR this:type) eval;\n';
	res += 'BEGIN\n';
	var c = x.txt;
	var isThis = function ( id, a ) {
		for ( var i = 0, l = a.length; i < l; i++ ) {
			var r = regExpIdTp.exec( a[i] );
			if ( r[1] == id ) return true;
		};
		return false;
	}
	for ( var i in c ) {
		var dstId = regExpIdTp.exec( c[i][1] );
		dstId = dstId[1];
		var dstFld = c[i][2];
		switch ( c[i][0] ) {
			case 'cset':
				res += '\tthis.' + dstId + ( dstFld ? "." + dstFld : "" ) + ' := ' + c[i][3] + ';\n';
				break;
			case 'set':
				var srcId = regExpIdTp.exec( c[i][3] );
				srcId = srcId[1];
				var srcFld = c[i][4];
				res += '\tthis.' + dstId + ( dstFld ? "." + dstFld : "" ) + ' := this.'
					+ srcId + ( srcFld ? "." + srcFld : "" ) + ';\n';
				break;
			case 'call':
				res += '\tthis.' + dstId + '.eval();\n';
				break;
		};
	};
	res += 'END eval;\n\n';
	res += 'END ' + moduleId + '.\n';
	return res;
}
FBDEditor.model.prototype.oberonCodeCreator.fileExt = ".O2";
